<template>
	<view class="zone">
		<Header title="发布求购"></Header>
		<view class="main">
			<image class="yun" src="http://image.qxgm.site/tdz/img/public/m_yun.png" mode="widthFix"></image>
			<image class="ping1" src="http://image.qxgm.site/tdz/img/public/ping1.png" mode="widthFix"></image>
			<view class="box">

				<scroll-view scroll-y class="scrollbox">
					<view class="list">
						<view class="item" v-for="(item , index) in list" :key="index">
							<view class="time">
								上架时间:{{item.create_time}}
							</view>
							<view class="left">
								<view class="imgbox">
									<image :src="item.props.img" mode="widthFix" />
									<view class="sjjaj" v-if="item.props.grade">
										{{item.props.grade.grade_name}}
									</view>
								</view>
								<view class="word">
									<p class="wp1">{{item.props.name}} 单价: <text>{{item.price}}灵石</text></p>
									<text>出售数量:{{item.num}}个</text>
								</view>
								<view class="button" @click="xiajia(item)">下架</view>
							</view>
						</view>

					</view>

					<view v-if="list.length==0" class="empty">
						<image src="http://img.cpgm.cc/xfmz/static/public/empty.png" mode="widthFix" />
						<text class="hui">
							没有数据哦~
						</text>
					</view>
				</scroll-view>

				<view class="fachubtn" @click="$p.navto('/pages/index/my_wantdetail')">
					发布求购
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
			}
		},
		onLoad() {},
		onShow() {
			this.myBuyList();
		},
		methods: {
			// 我的求购列表
			async myBuyList() {
				let res = await this.$http.index.marketMyorderList({
					deal_type: 1
				})
				if (res.code == 1) {
					this.list = res.data
					console.log(this.list[0].props);
				}
			},
			async xiajia(item) {
				let res = await this.$http.index.marketOffshelf({
					order_id: item.id
				})
				if (res.code == 1) {
					this.myBuyList();
				}
				this.$u.toast(res.msg)
			}
		}
	}
</script>

<style lang="less">
	.zone {
		min-height: 100vh;
		background: url(http://image.qxgm.site/tdz/img/public/p_bg.png) no-repeat;
		background-size: 100% auto;
	}

	.main {
		width: 100%;
		position: relative;
		margin-top: 10px;
	}

	.yun {
		position: absolute;
		top: -4%;
		left: 0;
		width: 44%;
		z-index: 9;
	}

	.ping1 {
		width: 100%;
		display: flex;
	}

	.box {
		background: url(http://image.qxgm.site/tdz/img/public/ping2.png);
		background-size: 100% auto;
		padding: 0px 6px 9px;
	}

	.item {
		background: url(http://image.qxgm.site/tdz/img/market/mg-07.png) no-repeat;
		background-size: 100% 100%;
		margin-bottom: 4px;

		.time {
			font-size: 12px;
			color: #FFFFFF;
			font-weight: normal;
			line-height: 12px;
			padding: 4px 0 4px 7px;
			margin-left: 1px;
			margin-bottom: 3px;
			background: url(http://image.qxgm.site/tdz/img/market/mg-06.png) no-repeat;
			background-size: 100% 100%;
		}

		.left {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 16px 7px 7px;

			.imgbox {
				position: relative;
				width: 60px;
				padding: 2px 4px;
				box-sizing: border-box;
				background: url(http://image.qxgm.site/tdz/img/liandan/tanbg.png) no-repeat;
				background-size: 100% 100%;

				image {
					width: 100%;
				}

				.sjjaj {
					position: absolute;
					right: 3px;
					bottom: 3px;
					font-size: 12px;
					color: #fff;
				}
			}

			.word {
				flex: 1;
				margin-left: 7px;

				.wp1 {
					font-size: 16px;
					font-weight: normal;
					color: #333333;
					line-height: 18px;
					margin-bottom: 8px;

					text {
						color: #FF0000;
					}
				}

				text {
					font-weight: normal;
					font-size: 15px;
					color: #333333;
					line-height: 15px;
				}

			}

			.button {
				display: block;
				margin: 18px auto;
				width: 63px;
				height: 37px;
				text-align: center;
				font-size: 16px;
				color: #fef7c8;
				text-shadow: 0 1px 1px #CB6500;
				line-height: 37px;
				font-weight: normal;
				background: url(http://image.qxgm.site/tdz/img/public/btn2.png) no-repeat;
				background-size: 100% 100%;
			}
		}


	}

	.scrollbox {
		height: calc(100vh - 179px);
		overflow-y: scroll;
	}

	.fachubtn {
		display: block;
		margin: 18px auto;
		width: 116px;
		height: 37px;
		text-align: center;
		font-size: 16px;
		color: #fef7c8;
		text-shadow: 0 1px 1px #CB6500;
		line-height: 37px;
		font-weight: normal;
		background: url(http://image.qxgm.site/tdz/img/public/anniu.png) no-repeat;
		background-size: 100% 100%;
	}
</style>